<!DOCTYPE html>
<html lang="en">
	<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<title>LMultitouch</title>
	<script type="text/javascript" src="../../lufylegend-1.8.12.min.js"></script>
	</head>
	<body>
			<div id="legend"></div>
<script>
init(1000/50,"legend",800,450,main);
var layer,back,txt = [],tt;
function main(){
	if(LGlobal.canTouch){
		LGlobal.stageScale = LStageScaleMode.EXACT_FIT;
		LSystem.screen(LStage.FULL_SCREEN);
	}
	LMultitouch.inputMode = LMultitouchInputMode.TOUCH_POINT;

	layer = new LSprite();
	layer.graphics.drawRect(2,"#ffffff",[0,0,LGlobal.width,LGlobal.height],true,"#ffffff");
	addChild(layer);
	back = new LSprite();
	back.y = 50;
	layer.addChild(back);
	tt = new LTextField();
	tt.size = 18;
	tt.x = 10;
	tt.y = 5;
	layer.addChild(tt);
	if(!LGlobal.canTouch){
		tt.text = "多点触屏测试：请用手机或平板电脑测试";
	}else{
		tt.text = "多点触屏测试：请点击屏幕进行测试";
	}
	layer.addEventListener(LMouseEvent.MOUSE_DOWN,ondown);
	layer.addEventListener(LMouseEvent.MOUSE_MOVE,onmove);
	layer.addEventListener(LMouseEvent.MOUSE_UP,onup);
}
function draw(){
	back.removeAllChild();
	for(var i=0;i<txt.length;i++){
		var eve = txt[i];
		var title = new LTextField();
		title.text = "id:"+eve.touchPointID+","+eve.offsetX+","+eve.offsetY;
		title.size = 18;
		title.x = 10;
		title.y = i*23;
		back.addChild(title);
	}
}
function setTTT(e){
	var f = false;
	for(var i=0;i<txt.length;i++){
		if(txt[i].touchPointID == e.touchPointID){
			txt[i] = e;
			f = true;
			break;
		}
	}
	if(!f)txt.push(e);
	draw();
}
function ondown(e){
	setTTT(e);
}
function onmove(e){
	setTTT(e);
}
function onup(e){
	for(var i=0;i<txt.length;i++){
		if(txt[i].touchPointID == e.touchPointID){
			txt.splice(i,1);
			break;
		}
	}
	draw();
}
</script>
	</body>
</html>
